* Yusaku Horiuchi, Jun Saito
* Replication of: "Reapportionment and Redistribution: Consequences of Electoral Reform in Japan"
* American Journal of Political Science, Vol. 47, No. 4, pp. 669-682
* Publication Date: October 2003

clear
clear matrix
set memory 30m
set more off
use ajps2003, clear
tsset muncode year

gen lnKofuPC= ln((F0017+F0018)/P2000)
gen lnFutsuPC= ln(F0017/P2000)
gen lnTokuPC= ln(F0018/P2000)
gen lnKokkoPC= ln(F0023/P2000)
gen lnHojoPC= ln((F0017+F0018+F0023)/P2000)

gen lnMal=ln(Mal/(10^6))
gen lnPop=ln(P2000)
gen lnArea=ln(area)
gen lnAreaPC=ln(P2000/area)
gen young =P0020/P2000
gen old =P0022/P2000
gen industry1=P0096/(P0096+P0100+P0104)
gen industry2=P0100/(P0096+P0100+P0104)
gen industry3=P0104/(P0096+P0100+P0104)
gen lnIncomePC=ln(C0217/P2000)
gen lnMalLDPSS=lnMal*LDPSS

/* Estimate F0131 for Tokyo 23 Wards */
gen  RDRatio= F0100/F0101
replace F0131=round(1/3*(RDRatio+L.RDRatio+L2.RDRatio), .01) if muncode>=13101 & muncode<=13123

/* Minor Adjustment for DID Population */
replace P0071=0 if P0071<5000 
/* If an interpolate or exprapolate value is less than 5,000, replace it with zero. This is because 
if P0071 becomes lower than 5,000, then in the next Census, the area will not be designated at DID. */
gen urban=P0071/P0001

/* Drop observations with non-sensical extrapolation */
gen drop=0
replace drop=1 if young<0
replace drop=1 if old<0
replace drop=1 if industry1<0
replace drop=1 if industry2<0
replace drop=1 if industry3<0
replace drop=1 if urban<0

/* A dummy for Tokyo 23 Wards */
gen Tokyo23=(muncode>=13101 & muncode<=13123)

/* A dummy for cities designated by ordinance */
gen seirei=0
replace seirei=1 if muncode==1100
replace seirei=1 if muncode==4100 & year>=1989
replace seirei=1 if muncode==12100 & year>=1992 
replace seirei=1 if muncode==14100
replace seirei=1 if muncode==14130
replace seirei=1 if muncode==23100 
replace seirei=1 if muncode==26100
replace seirei=1 if muncode==27100
replace seirei=1 if muncode==28100 
replace seirei=1 if muncode==34100 & year>=1980
replace seirei=1 if muncode==40100
replace seirei=1 if muncode==40130

/* A dummy for municipalities affected by Great Hanshin Earthquake  */
/* Source: http://www.pure.co.jp/~ngo/haeq/eq-damage.html (accessed on March 24, 2002) */
gen shinsai=0
replace shinsai=1 if muncode==28100
replace shinsai=1 if muncode==28202
replace shinsai=1 if muncode==28203
replace shinsai=1 if muncode==28204
replace shinsai=1 if muncode==28205
replace shinsai=1 if muncode==28206
replace shinsai=1 if muncode==28207
replace shinsai=1 if muncode==28214
replace shinsai=1 if muncode==28215
replace shinsai=1 if muncode==28217
replace shinsai=1 if muncode==28681
replace shinsai=1 if muncode==28682
replace shinsai=1 if muncode==28683
replace shinsai=1 if muncode==28684
replace shinsai=1 if muncode==28685
replace shinsai=1 if muncode==28686
replace shinsai=1 if muncode==28701
replace shinsai=1 if muncode==28702
replace shinsai=1 if muncode==28703
replace shinsai=1 if muncode==28704

/* Regression Analysis */

local y lnHojoPC
local x lnMal LDPSS F0131 lnPop lnAreaPC lnIncomePC young old industry1 industry3 urban seirei

reg `y' `x' if year==1991 & drop==0, robust
reg `y' `x' if year==1992 & drop==0, robust
reg `y' `x' if year==1993 & drop==0, robust
reg `y' `x' shinsai if year==1994 & drop==0, robust

reg `y' `x' shinsai if year==1995 & drop==0, robust
reg `y' `x' shinsai if year==1996 & drop==0, robust
reg `y' `x' shinsai if year==1997 & drop==0, robust
reg `y' `x' shinsai if year==1998 & drop==0, robust

keep if year==1992 | year==1995 | year==1998

gen     year2=1 if year==1992
replace year2=2 if year==1995
replace year2=3 if year==1998
tsset muncode year2

local control D.LDPSS D.F0131 D.lnPop D.lnIncomePC D.young D.old D.industry1 D.industry3 D.urban shinsai

reg D.lnHojoPC D.lnMal       `control'  if year2==2 & drop==0, robust
reg D.lnHojoPC lnMal L.lnMal `control'  if year2==2 & drop==0, robust

reg D.lnHojoPC D.lnMal       `control'  if year2==3 & drop==0, robust
reg D.lnHojoPC lnMal L.lnMal `control'  if year2==3 & drop==0, robust






